home *** CD-ROM | disk | FTP | other *** search
- Path: lrz-muenchen.de!news
- From: watzka@stat.uni-muenchen.de (Kurt Watzka)
- Newsgroups: comp.lang.c
- Subject: Re: Stylistic Concerns with Header Files
- Date: 21 Apr 1996 15:22:10 GMT
- Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
- Distribution: world
- Message-ID: <4ldjr2$88p@sparcserver.lrz-muenchen.de>
- References: <4lb9bl$amo@wormer.fn.net>
- NNTP-Posting-Host: sun2.lrz-muenchen.de
-
- withheld@keepitpublic.com (Rusty Meathook) writes:
-
- >I occasionally create the undesirable situation of having to include
- >my header files in a certain order, or having to include one header
- >file to include another, and I was wondering how I can circumvent
- >that.
-
- [Two heades where header two needs header one edited]
-
- >Of course, these are intentionally simple examples, and there are
- >obvious ways to solve the problem by merging the two header files.
- >Imagine, however, that it is undesirable to merge the header files --
- >each of them deals with a different library of functions, and need to
- >be kept seperate to maintain modularity.
-
- >The obvious problem, now, is that a source file that needs to use
- >"foo.h" will have to include "bar.h" prior to including "foo.h", which
- >is a nasty situation stylistically. Including another header file
- >within a header file is even worse.
-
- Why is this "worse"? You either have to include header files in a
- certain order, or every header file has to include all the header
- files needed by that header file. The
-
- #ifndef INCL_FOO_H
- #define INCL_FOO_H
-
- #endif
-
- construct prevents multiple inclusions of a header files contents.
-
- From a maintainers point of view, I prefer this scheme over having
- to know which other header files have to be included before you can
- include a given header file.
-
- You _do_ have a problem if there are circular dependencies, but they
- usually can be solved using forward references.
-
- Kurt
- --
- | Kurt Watzka Phone : +49-89-2180-6254
- | watzka@stat.uni-muenchen.de
-